/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import java.util.Collection;

import ms.unicorn.language.languagedef.ConnectionDecorator;
import ms.unicorn.language.languagedef.LanguagedefPackage;
import ms.unicorn.language.languagedef.Parameter;
import ms.unicorn.language.languagedef.XReferenceExpression;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connection Decorator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ConnectionDecoratorImpl#getParamaters <em>Paramaters</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ConnectionDecoratorImpl#getDecorator <em>Decorator</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConnectionDecoratorImpl extends MinimalEObjectImpl.Container implements ConnectionDecorator
{
  /**
   * The cached value of the '{@link #getParamaters() <em>Paramaters</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParamaters()
   * @generated
   * @ordered
   */
  protected EList<Parameter> paramaters;

  /**
   * The cached value of the '{@link #getDecorator() <em>Decorator</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDecorator()
   * @generated
   * @ordered
   */
  protected XReferenceExpression decorator;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConnectionDecoratorImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.CONNECTION_DECORATOR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Parameter> getParamaters()
  {
    if (paramaters == null)
    {
      paramaters = new EObjectContainmentEList<Parameter>(Parameter.class, this, LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS);
    }
    return paramaters;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XReferenceExpression getDecorator()
  {
    return decorator;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDecorator(XReferenceExpression newDecorator, NotificationChain msgs)
  {
    XReferenceExpression oldDecorator = decorator;
    decorator = newDecorator;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR, oldDecorator, newDecorator);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDecorator(XReferenceExpression newDecorator)
  {
    if (newDecorator != decorator)
    {
      NotificationChain msgs = null;
      if (decorator != null)
        msgs = ((InternalEObject)decorator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR, null, msgs);
      if (newDecorator != null)
        msgs = ((InternalEObject)newDecorator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR, null, msgs);
      msgs = basicSetDecorator(newDecorator, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR, newDecorator, newDecorator));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS:
        return ((InternalEList<?>)getParamaters()).basicRemove(otherEnd, msgs);
      case LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR:
        return basicSetDecorator(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS:
        return getParamaters();
      case LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR:
        return getDecorator();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS:
        getParamaters().clear();
        getParamaters().addAll((Collection<? extends Parameter>)newValue);
        return;
      case LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR:
        setDecorator((XReferenceExpression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS:
        getParamaters().clear();
        return;
      case LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR:
        setDecorator((XReferenceExpression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.CONNECTION_DECORATOR__PARAMATERS:
        return paramaters != null && !paramaters.isEmpty();
      case LanguagedefPackage.CONNECTION_DECORATOR__DECORATOR:
        return decorator != null;
    }
    return super.eIsSet(featureID);
  }

} //ConnectionDecoratorImpl
